package com.gm.wj.controller;


import com.gm.wj.entity.WorkPublish;
import com.gm.wj.entity.WorkSubmit;
import com.gm.wj.result.Result;
import com.gm.wj.result.ResultFactory;
import com.gm.wj.service.WorkSubmitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/workSubmit")
public class WorkSubmitController {

    @Autowired
    private WorkSubmitService workSubmitService;

    /**
     * 获取列表
     * @return
     */
    @GetMapping("/list")
    public Result list() {
        return ResultFactory.buildSuccessResult(workSubmitService.list());
    }

    /**
     * 保存
     * @param entity
     * @return
     */
    @PostMapping("/save")
    public Result save(@RequestBody WorkSubmit entity) {
        return ResultFactory.buildSuccessResult(workSubmitService.save(entity));
    }

    /**
     * 修改分数
     * @param
     * @return
     */
    @PostMapping("/updateScore")
    public Result updateScore(@RequestParam("id") Integer id,@RequestParam("score") Double score) {
        return ResultFactory.buildSuccessResult(workSubmitService.updateScore(id,score));
    }



    /**
     * 删除
     * @param id
     * @return
     */
    @PostMapping("/delete/{id}")
    public Result delete(@PathVariable("id") Integer id) {
        return ResultFactory.buildSuccessResult(workSubmitService.delete(id));
    }
}
